﻿using Shop.RemoteModel.Advert.Model;
using Shop.StoreGatewayModular.Interface;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    [ApiRouteName("/shop/advert/{name}")]
    internal class AdvertApi : ApiController
    {
        private readonly IAdvertService _Service;

        public AdvertApi (IAdvertService service)
        {
            this._Service = service;
        }

        public long Add (AdvertAdd data)
        {
            return this._Service.Add(data);
        }
        public void End ([NumValidate("shop.advert.id.error", 1)] long id)
        {
            this._Service.End(id);
        }
        public void Delete ([NumValidate("shop.advert.id.error", 1)] long id)
        {
            this._Service.Delete(id);
        }
        public void Enable ([NumValidate("shop.advert.id.error", 1)] long id)
        {
            this._Service.Enable(id);
        }
        public AdvertDto Get ([NumValidate("shop.advert.id.error", 1)] long id)
        {
            return this._Service.Get(id);
        }
        public void Stop ([NumValidate("shop.advert.id.error", 1)] long id)
        {
            this._Service.Stop(id);
        }
        public PagingResult<AdvertBase> Query (PagingParam<AdvertQueryParam> param)
        {
            return this._Service.Query(param);
        }
        public bool Set (LongParam<AdvertSet> param)
        {
            return this._Service.Set(param.Id, param.Value);
        }
    }
}
